]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
swipeTracker: Reject touch swipes in the wrong directions
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 3 Feb 2021 15:54:25 +0000 (16:54 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 17 Feb 2021 13:06:11 +0000 (14:06 +0100)
We now have multiple touch swipe gestures with matching fingers and
different directions set on the overview hierarchy. Accepting all
touch swipes without checking the direction makes one of these gestures
take control of input, without other gestures having a say on this.

So, look for the direction of the touch events and look if it matches
the expected orientation before accepting the gesture.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1643>

js/ui/swipeTracker.js

index cf5e01d716b529d2ea1168a96ad1a4ff5c94d8fd..1bd8a69c9d52bb20d8dfa94b6a2e7319cf2805f6 100644 (file)
@@ -247,6 +247,12 @@ const TouchSwipeGesture = GObject.registerClass({
         let time = this.get_last_event(0).get_time();
         let [xPress, yPress] = this.get_press_coords(0);
         let [x, y] = this.get_motion_coords(0);
+        const [xDelta, yDelta] = [x - xPress, y - yPress];
+        const swipeOrientation = Math.abs(xDelta) > Math.abs(yDelta)
+            ? Clutter.Orientation.HORIZONTAL : Clutter.Orientation.VERTICAL;
+
+        if (swipeOrientation !== this.orientation)
+            return false;
 
         this._lastPosition =
             this.orientation === Clutter.Orientation.VERTICAL ? y : x;